package com.tange.ai.iot.client.gnssa

import android.content.Context
import android.content.Intent
import android.util.Log
import com.alibaba.sdk.android.push.MessageReceiver
import com.alibaba.sdk.android.push.notification.CPushMessage
import com.tange.ai.iot.client.gnssa.home.HomeActivity

class PushMessageReceiver: MessageReceiver() {

    companion object {
        const val TAG = "_PushMessageReceiver_"
    }

    override fun onNotificationOpened(p0: Context?, p1: String?, p2: String?, p3: String?) {
        Log.i(TAG, "[onNotificationOpened] $p1 , $p2 , $p3")
        p0?.let {
            it.startActivity(Intent(it, HomeActivity::class.java).apply {
                addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
            })
        }
    }

    override fun onNotificationRemoved(p0: Context?, p1: String?) {
        Log.i(TAG, "[onNotificationRemoved] ")
    }

    override fun onNotification(
        p0: Context?,
        p1: String?,
        p2: String?,
        p3: MutableMap<String, String>?
    ) {
        Log.i(TAG, "[onNotification] $p1 , $p2 , $p3")
    }

    override fun onMessage(p0: Context?, p1: CPushMessage?) {
        Log.i(TAG, "[onMessage] ")
    }

    override fun onNotificationClickedWithNoAction(
        p0: Context?,
        p1: String?,
        p2: String?,
        p3: String?
    ) {
        Log.i(TAG, "[onNotificationClickedWithNoAction] ")
    }

    override fun onNotificationReceivedInApp(
        p0: Context?,
        p1: String?,
        p2: String?,
        p3: MutableMap<String, String>?,
        p4: Int,
        p5: String?,
        p6: String?
    ) {
        Log.i(TAG, "[onNotificationReceivedInApp] ")
    }
}